/**
 * FileChooseActivity
 */
package info.niwota.home.fm;

import info.niwota.home.R;
import instant.openvfs.home.Preferences;
import x.java.io.File;
import android.os.Bundle;
import android.view.View;

/**
 * 
 * @author qiangli
 * 
 */
public class FileChooseActivity extends FileBrowseActivity {
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		//
		//footer.setVisibility(View.GONE);
		selected.setVisibility(View.VISIBLE);
		buttons.setVisibility(View.VISIBLE);
		//
		// last saved
		File f = readPath();
		//
		f.refresh();
		doSelectFolder(f);
	}


	@Override
	protected File readPath() {
		String p = Preferences.getLastPickPath(this, "/");
		File f = new File(p);
		f = (x.java.io.File) (f.isDirectory() ? f : f.getParentFile());
		return f;
	}


	@Override
	protected void savePath(File f) {
		String p = (f == null ? null : f.getPath());
		Preferences.putLastPickPath(this, p);
	}



	@Override
	protected void doFinish() {
		File f = selectedFolder;
		if (f.isRoot()) {
			//
		} else {
			doBack();
		}
	}
	protected void setSelectedText(File newfile) {
		String p = newfile.getPath();
		String t = getString(R.string.app_name_selected, p);
		setTitle(t);
		//
		selected.setText(p);
	}
}
